home *** CD-ROM | disk | FTP | other *** search
- Path: buggus.mmg.uci.edu!user
- From: mangalam@uci.edu (Harry Mangalam)
- Newsgroups: comp.lang.c
- Subject: Different stdout End-of-output with redir '>' and stdout to screen
- Date: Fri, 09 Feb 1996 17:59:18 -0800
- Organization: Microbiology and Molecular Genetics, UC Irvine
- Message-ID: <mangalam-0902961759180001@buggus.mmg.uci.edu>
- NNTP-Posting-Host: buggus.mmg.uci.edu
-
- HI All,
- This may not be a pure C question and for that I apologize. I'm
- writing a pure ansi C program (no comiler complaints under SGI's cc or gcc
- under Linux) that reads in a bunch of DNA sequence (acgt's), performs some
- manipulations and spits the output to stdout. It works surprisingly well
- (thanks, Steve Summit et al for the FAQ!! (which I've examined with no
- luck, although it could be boneheadedness on my part)), but I've run
- across an interesting/confusing bug/ignorance-on-my-part.
-
- When the output is allowed to dump to the screen, it does exactly what I
- expect it to do, but when the output is redirected to a file via ">", I
- get a duplication of the last part of the output. ie:
-
- to screen (correct output):
- .
- .
- .
- TfiI
- HinfI
- MboI NlaIII
- DpnII AlwI AflIII
- BsrI DpnI Tth111II NspI
- \ \ \ \ \ \ \
- 31921 gttccagtagcaagcataggatcaagaataataacatgtgaatcagagatgttttcaggc 31980
- caaggtcatcgttcgtatcctagttcttattattgtacacttagtctctacaaaagtccg
- ^ * ^ * ^ * ^ * ^ * ^ *
- V P V A S I G S R I I T C E S E M F S G
-
- SfaNI
- \
- 31981 atctttttatagtatgaaa 32040
- tagaaaaatatcatacttt
- ^ * ^ * ^ * ^ * ^ * ^ *
- I F L Z Y E
-
-
-
- to file via ">" (incorrect output):
- .
- .
- .
- TfiI
- HinfI
- MboI NlaIII
- DpnII AlwI AflIII
- BsrI DpnI Tth111II NspI
- \ \ \ \ \ \ \
- 31921 gttccagtagcaagcataggatcaagaataataacatgtgaatcagagatgttttcaggc 31980
- caaggtcatcgttcgtatcctagttcttattattgtacacttagtctctacaaaagtccg
- ^ * ^ * ^ * ^ * ^ * ^ *
- V P V A S I G S R I I T C E S E M F S G
-
- SfaNI
- \
- 31981 atctttttatagtatgaaa 32040
- tagaaaaatatcatacttt
- ^ * ^ * ^ * ^ * ^ * ^ *
- I F L Z Y E
-
- ^ *
- I F L Z Y E
-
- Note last 2 lines - this can be of variable length, repeating up to 30 or
- more lines of the last part of the output.
-
- This sounds like it might be the failure to correctly terminate a string,
- leading to a 'run-on' past the supposed end of the string, but the program
- clears that chunk of memory via a memset call (verified to work correctly
- with a debugger), so that even if it ran on, it shouldn't be intelligible
- characters. It 'feels like' the system is clearing a buffer to stdout at
- program termination.
-
- I've tried:
- fflush (stdout);
- and
- fclose (stdout);
- with no difference in output.
-
- Is there a system call to terminate anything more going out to stdout?
- And if something like that was involved, why would the output to screen
- work correctly all the time?
- This has been tried and works identically on IRIX 5.3 and Linux 1.2.8.
-
-
- Any direct insight or rtfm pointers would be appreciated.
- Thanks and Cheers
- harry
- --
- Harry J Mangalam, Microbiology and Molecular Genetics, UC Irvine,
- Irvine, CA, 92717, (714) 824-4824, fax (714) 824 8598
- http://hornet.mmg.uci.edu/~hjm/hjm.html
- Computational Biology..SGI..Woodworking..Bicycling..Linux..WWW
-